n=int(input())
if 999<n<10000:
      k=0
      for i in range (2,n//n):
            if n % i == 0:
                  k+=1
            if k == 0:
                  print(n)
            else:
                  n1 =  n % 1000
                  n2 = n // 10
else:
      print(0)
